class MyRunnable implements Runnable{
    @Override
    public void run() {
        while(true){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("hello Thread!");
        }
    }
}
public class Demo2 {
    public static void main(String[] args) throws InterruptedException {
        Runnable runnable = new MyRunnable();
        Thread t = new Thread(runnable);
        // 和第一种的区别是可以解耦合
        // 解耦合:可以把任务拆解出来放入Thread中
        // 解耦合让他们之间的影响变小
        t.start();
        while(true){
            Thread.sleep(1000);
            System.out.println("hello main!");
        }
    }
}
